Skip to content

Conversation

@eejbyfeldt
Copy link
Contributor

My understanding is that the test case in i24504 is expected to take
this branch:

else if unappResult.info <:< defn.NonEmptyTupleTypeRef then

where we the info is comming from
private def letAbstract(rhs0: Tree, tpe: Type = NoType)(body: Symbol => Plan): Plan = {
val rhs = dropNamedTuple(rhs0)
val declTpe = if tpe.exists then tpe else rhs.tpe
val vble = newVar(rhs, EmptyFlags, declTpe)
initializer(vble) = rhs
LetPlan(vble, body(vble))
}

that has called dropNamedTuple
private def dropNamedTuple(tree: Tree): Tree =
val tpe = tree.tpe.widenDealias
if tpe.isNamedTupleType then tree.cast(tpe.stripNamedTuple) else tree

the problem is that under this case the type will be NamedTuple.From
for which isNamedTupleType returns false. Which means that the
returned type will not be a NonEmptyTupleType.

The fix in this mr adds a normalized.dealias call in
isNormalizedTupleType which brings it inline with
stripNormalizedTupleType. But seems feasible that a better fix could
be that NamedTuple.From should have already been removed earlier. But
it not clear to me if that possible.

fixes: #24504

My understanding is that the test case in i24504 is expected to take
this branch:
https://github.com/scala/scala3/blob/0470ec1ff46a822ca58e204587fb67d56004623a/compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala#L420
where we the info is comming from
https://github.com/scala/scala3/blob/0470ec1ff46a822ca58e204587fb67d56004623a/compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala#L118-L124
that has called `dropNamedTuple`
https://github.com/scala/scala3/blob/0470ec1ff46a822ca58e204587fb67d56004623a/compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala#L113-L115

the problem is that under this case the type will be `NamedTuple.From`
for which `isNamedTupleType` returns false. Which means that the
returned type will not be a `NonEmptyTupleType`.

The fix in this mr adds a `normalized.dealias` call in
`isNormalizedTupleType` which brings it inline with
`stripNormalizedTupleType`. But seems feasible that a better fix could
be that `NamedTuple.From` should have already been removed earlier. But
it not clear to me if that possible.

fixes: i24504
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

assertion failure in PatternMatcher when returning dependent NamedTuple.From

1 participant